package com.dou.sample.opengl_project.data;

import com.dou.sample.opengl_project.objects.ObjectBuilder;
import com.dou.sample.opengl_project.shader.ColorShaderProgram;
import com.dou.sample.opengl_project.utls.GeoMetry;

import java.util.List;

/**
 * Created by Dou on 2018/1/17.
 */

public class Puck {
    private static final int POSITION_COMONENT_COUNT = 3;

    VertexArray vertexArray;
    List<ObjectBuilder.DrawCommand> drawList;

    public float radius, height;

    public Puck(float radius, float height, int numPoint){

        ObjectBuilder.GenerateData generateData = ObjectBuilder.createPuck(new GeoMetry.Cylinder(new GeoMetry.Point(0,0,0), radius, height), numPoint);

        this.radius = radius;
        this.height = height;

        vertexArray = new VertexArray(generateData.vertexData);

        drawList = generateData.drawList;
    }

    public void bindData(ColorShaderProgram colorShaderProgram){
        vertexArray.setVertexAttributePointer(0, colorShaderProgram.getuColorLocation(), POSITION_COMONENT_COUNT, 0);
    }

    public void draw(){
        for (ObjectBuilder.DrawCommand drawCommand : drawList){
            drawCommand.draw();
        }
    }
}
